<?php
// header("Location:index.php");
require 'membersession.class.php' ;

require 'admin/sql.class.php';

$mobile = "";

if (empty($_POST["mobile"])) {
	exit("请先填写手机号!");
}

if (empty($_POST["password"])) {
	exit("请先填写密码!");
}

$mobile = $_POST["mobile"];
$password = $_POST["password"];

// 先去数据库查找这个手机号
$arr = searchMemberFromMobile($mobile);
if (count($arr) == 0) {
	exit("没有找到该手机号");
}

// 验证密码
if ($password != $arr[0]["password"]) {
	exit("<script language='javascript'>alert('密码错误!');window.location.href='login.php'; </script>");
} 

$avatar = $arr[0]["avatar"];
$username = $arr[0]["username"];
$nickname = $arr[0]["nickname"];
$gender = $arr[0]["gender"];
// 登录成功
MemberSessionInfo::setLoginInfo("MemberMobile", $mobile);
MemberSessionInfo::setLoginInfo("MemberPassword", $password);
MemberSessionInfo::setLoginInfo("MemberUsername", $username);
MemberSessionInfo::setLoginInfo("MemberAvatar", $avatar);
MemberSessionInfo::setLoginInfo("MemberNickname", $nickname);
MemberSessionInfo::setLoginInfo("MemberGender", $gender);

echo("<script language='javascript'>alert('登录成功!');window.top.location.href='/mcnews/index.php'</script>");


// echo("<script language='javascript'>window.top.location.href='/mcnews/index.php'</script>");
?>